﻿<UserControl
    x:Class="WPFLOBMVVM.View.EditContactsAjaxComboBoxSelectionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:WPFLOBMVVM.View"
    xmlns:Ocean_WPF="clr-namespace:Ocean.OceanFramework.WPF;assembly=OceanFrameworkWPF"
    xmlns:Ocean_MVVM="clr-namespace:Ocean.OceanFramework.MVVM;assembly=OceanFrameworkWPF"
    xmlns:be="clr-namespace:BusinessEntityObjects;assembly=BusinessEntityObjects">
    <UserControl.Resources>
        <ItemsPanelTemplate x:Key="cboVirtualizingPanelTemplate">
            <VirtualizingStackPanel IsItemsHost="True" IsVirtualizing="True" />
        </ItemsPanelTemplate>

        <DataTemplate x:Key="searchByContactLastName" DataType="{x:Type be:ContactSearchResult}">
            <StackPanel Orientation="Horizontal">
                <StackPanel.Resources>
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="Margin" Value="5,2,0,0"/>
                        <Setter Property="Width" Value="100"/>
                    </Style>
                </StackPanel.Resources>
                <TextBlock Text="{Binding Path=LastName}" Margin="0,2,0,0"/>
                <TextBlock Text="{Binding Path=FirstName}"/>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>

    <DockPanel LastChildFill="True">

        <Grid DockPanel.Dock="Top" HorizontalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <ToolBarTray VerticalAlignment="Top" >
                <ToolBar>
                    <Ocean_WPF:CustomToolBarButton Command="{Binding Path=NewCommand}" ShowButtonText="True" ShowButtonImage="True" ButtonLayout="Horizontal" ButtonText="New" EnabledButtonImage="../Resources/Images/New.png" ToolTip="Create new contact" DisabledButtonImage="../Resources/Images/NewDisabled.png" MouseOverForeground="Black" />
                    <Ocean_WPF:CustomToolBarButton Command="{Binding Path=SaveCommand}" ShowButtonText="True" ShowButtonImage="True" ButtonLayout="Horizontal" ButtonText="Save" EnabledButtonImage="../Resources/Images/Save.png" ToolTip="Save contact" DisabledButtonImage="../Resources/Images/SaveDisabled.png"  MouseOverForeground="Black" />
                    <Separator Focusable="False" />
                    <Ocean_WPF:CustomToolBarButton Command="{Binding Path=DeleteCommand}" ShowButtonText="True" ShowButtonImage="True" ButtonLayout="Horizontal" ButtonText="Delete" EnabledButtonImage="../Resources/Images/Delete.png" ToolTip="Delete contact" DisabledButtonImage="../Resources/Images/DeleteDisabled.png" MouseOverForeground="Black" />
                </ToolBar>
            </ToolBarTray>

            <Ocean_WPF:CustomToolBarButton Command="{Binding Path=RequestCloseCommand}" ButtonText="Close" EnabledButtonImage="../Resources/Images/Close.png" ToolTip="Close contact form" DisabledButtonImage="../Resources/Images/CloseDisabled.png" Grid.Column="2" VerticalAlignment="Top"/>
        </Grid>

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Horizontal" Margin="7">
                <TextBlock Text="Select Contact" Margin="0,0,7,0" VerticalAlignment="Center" HorizontalAlignment="Left" />
                <Ocean_WPF:AjaxStyleComboBox 
                    Width="200"
                    x:Name="cboLastNameSearch"
                    MaxDropDownHeight="200"
                    MinimunSearchTextLength="1"
                    IsEditable="True"
                    SelectedValuePath="Id"
                    TextSearch.TextPath="LastName"
                    ItemsPanel="{StaticResource cboVirtualizingPanelTemplate}" 
                    ItemTemplate="{StaticResource searchByContactLastName}"/>
            </StackPanel>

            <local:ContactView x:Name="objContactView" Grid.Row="1" DataContext="{Binding ContactViewModel}" />

        </Grid>

    </DockPanel>

</UserControl>
